package imwej.android.app;

import java.util.ArrayList;
import java.util.List;

import android.content.Context;
import android.widget.ArrayAdapter;

public class PieAdapter extends ArrayAdapter<PieAdapter.LabelValue> {
	
	private int group_id = 0;
	private List<List<LabelValue>> items = new ArrayList<List<LabelValue>>();

	public PieAdapter(Context context) {
		super(context, android.R.layout.simple_list_item_1);
	}
	
	public void setGroup(int group_id) {
		this.group_id = group_id;
	}
	
	public void addGroup(List<PieAdapter.LabelValue> value) {
		items.add(value);
	}
	
	@Override
	public LabelValue getItem(int position) {
		return items.get(group_id).get(position);
	}
	
	@Override
	public long getItemId(int position) {
		return position;
	}
	
	@Override
	public int getCount() {
		if (items.size() > 0)
			return items.get(group_id).size();
		return 0;
	}

	public static class LabelValue {
		public String label = "label";
		public double value = 0;
		public LabelValue(String label) {
			this.label = label;
		}
		public LabelValue(double value) {
			this.value = value;
		}
		public LabelValue(String label, double value) {
			this.label = label;
			this.value = value;
		}
	}
}
